import {myFetch} from '@/assets/js/utils.js'

export default{
    // 获取地址列表
    async getAddressList () {
        const data = await myFetch({
            name: 'shopping.sys.address.list'
        })
        return data
    },
    // 新增地址
    async addAddress ({receive_name, receive_mobile,
        receive_province, receive_city,
        receive_area, receive_address, selected}) {
        const data = await myFetch({
            name: 'shopping.sys.address.add',
            receive_name,
            receive_mobile,
            receive_province,
            receive_city,
            receive_area,
            receive_address,
            receive_myname: '',
            receive_IDnumber: '',
            receive_myphone: '',
            selected: Number(selected)
        })
        return data
    },
    // 编辑地址
    async editAddress ({address_id, receive_name, receive_mobile,
        receive_province, receive_city,
        receive_area, receive_address, selected}) {
        const data = await myFetch({
            name: 'shopping.sys.address.update',
            address_id,
            receive_name,
            receive_mobile,
            receive_province,
            receive_city,
            receive_area,
            receive_address,
            receive_myname: '',
            receive_IDnumber: '',
            receive_myphone: '',
            selected: Number(selected)
        })
        return data
    },
    // 删除地址
    async removeAddress (addressId) {
        const data = await myFetch({
            name: 'shopping.sys.address.del',
            address_id: addressId,
            user_id: 0
        })
        return data
    }
}
